
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[InitializePlayerAsset] 
	@Game_ID numeric(10,0) = null
AS
BEGIN 
	DECLARE @ID int
	DECLARE IDs CURSOR LOCAL FOR 
		SELECT pe.[Player_ID] 
		FROM [dbo].[Player] p JOIN [dbo].[PlayerEnrollment] pe ON (p.player_id = pe.player_id and p.isActive = 'Y' and p.[type]= 'R') 
		WHERE pe.IsActive = 'Y'
			and pe.[Game_ID] = @Game_ID

	OPEN IDs
	FETCH NEXT FROM IDs into @ID
	WHILE @@FETCH_STATUS = 0
	BEGIN
		INSERT INTO [dbo].[PlayerAsset]([Game_ID],[Player_ID],[AssetType],[Land_ID],[GameCard_ID],[Currency]) VALUES(@Game_ID,@ID,'Cash',NULL,NULL,1500)

		FETCH NEXT FROM IDs into @ID
	END

	CLOSE IDs
	DEALLOCATE IDs
	

END

-- [dbo].[InitializePlayerAsset] 1